/**
**************************************************************************************
*Founder Effect                                                                      *
*Copyright (C) 2006-2007, 5d Studios (www.5d-Studios.com)                            *
*                                                                                    *
*This library is free software; you can redistribute it and/or                       *
*modify it under the terms of the GNU Lesser General Public                          *
*License as published by the Free Software Foundation; either                        *
*version 2.1 of the License, or (at your option) any later version.                  *
*                                                                                    *
*This library is distributed in the hope that it will be useful,                     *
*but WITHOUT ANY WARRANTY; without even the implied warranty of                      *
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                   *
*Lesser General Public License for more details.                                     *
*                                                                                    *
*You should have received a copy of the GNU Lesser General Public                    *
*License along with this library; if not, write to the Free Software                 *
*Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA      *
**************************************************************************************
*/
#pragma once


#include <string>

#include "EngineTypes.h"
#include "input/IKeyListener.h"
#include "input/IMouseListener.h"
/**
===============================
A gamestate is anything that alters the game,
which redirects input, or something that needs
separate rendering
===============================
*/
class IGameState : public IKeyListener, public IMouseListener
{
public:
    IGameState() : m_id( ID_TRACKER++ ), m_active( true ) {}
    /**
        Initialize the state - load 
        specific data, etc
    */
    virtual int Init()=0;

	/**
        Start, reinit anything that may have been
        uninitiliazed leaving the state
    */
	virtual int Start()=0;
    /**
        Update the world by a frame tick
    */
	virtual void Update(float dt)=0;
    /**
        Leave this game state
    */
	virtual void Exit()=0;
    /**
        Destroy and cleanup this state
    */
	virtual void Shutdown()=0;

    /** -------------------------------------------
            IKeyListener Interface
            A derived class may implement these functions
            if they require input

            NOTE:: They must request focus in order to
            take input!
    ----------------------------------------------- **/

    /** Get the Key pressed */
    virtual void KeyPressed( const KeyEvent* keyEvent )  {};

    /** Get the Key Released */
    virtual void KeyReleased( const KeyEvent* keyEvent ) {};

    /** -------------------------------------------
            IMouseListener Interface
            A derived class may implement these functions
            if they require input

            NOTE:: They must request focus in order to
            take input!
    ----------------------------------------------- **/

    /** A mouse button was pressed */
    virtual void MouseButtonPressed( MouseEvent* mEvent ) {};

    /** A mouse button was released */
    virtual void MouseButtonReleased( MouseEvent* mEvent ) {};

    /** Mouse Moved Event */
    virtual void MouseMotion( MouseEvent* mEvent ) {};


    /** Activate the State */
    bool IsActive() { return m_active; };
    void SetActive(bool b) { 
        m_active = b; 
        if ( !m_active ) {  
            SetKeyFocus( false ); SetMouseFocus( false );
        }
    };

    /** Each State has a unique ID */
    type_id GetID() { return m_id; };

    /** Get/Set the name of this state */
    std::string GetName() { return m_name; };
    void SetName(std::string name) { m_name = name; };

private:
    bool                m_active;                  // flag to test if this state is the current one
    static type_id      ID_TRACKER;                // Keeps track of unique ids
    type_id             m_id;                      // the ID of this state

    std::string         m_name;                    // name of the state - used for script references

};